<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class KnowledgeArticle extends Model
{
	use HasDateTimeFormatter;
    protected $table = 'eb_knowledge_article';

    public function info(){
        return $this->hasOne(KnowledgeArticleInfo::class,'article_id','id');
    }

    public function subject()
    {
        return $this->hasOne(KnowledgeArticleSubject::class,'id','subject');
    }
    public function subjectpid()
    {
        return $this->hasOne(KnowledgeArticleSubject::class,'id','subject_pid');
    }
    public function familyType(){
        return $this->belongsToMany(FamilyType::class,KnowledgeArticleType::class,'article_id','family_type_id');
    }
    public function hospitals(){
        return $this->belongsToMany(Hospital::class, HospitalAdminUserHospital::class, 'hsopital_admin_users_id', 'hospital_id');
    }

    public function notice(){
        return $this->hasOne(Notice::class,'article_id','id');
    }
}
